package algorithm.poj.p2000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;
import java.util.Arrays;


/**
 * 分析：
 * 实现：
 * 经验：
 * 教训：
 * 
 * @author wong.tong@gmail.com
 *
 */
public class P2371 {

	public static void main(String[] args) throws Exception {

		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P2371.class.getResource("P2371.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));

		String line = stdin.readLine();
		int N = Integer.valueOf(line.trim());
		int[] data = new int[N];
		for (int i = 0; i < N; i ++) {
			line = stdin.readLine();
			data[i] = Integer.valueOf(line.trim());
		}
		Arrays.sort(data);
		line = stdin.readLine();
		line = stdin.readLine();
		int K = Integer.valueOf(line.trim());
		StringBuffer sb = new StringBuffer("");
		for (int i = 0; i < K; i ++) {
			line = stdin.readLine();
			int index = Integer.valueOf(line.trim())-1;
			sb.append(data[index]).append("\n");
		}
		System.out.println(sb);
	}
}